

using System;
using System.Collections;
using CUtil;
using System.Xml.Serialization;

namespace CNeural
{

	/// <summary>
	/// Summary description for Pattern.
	/// </summary>
	public class NNPattern
	{
		private ArrayList arrayInput;
		private ArrayList arrayOutput;
		private ArrayList arrayCalculated;

		private static int nPatternID = 0;
		private int nCurrentID;


		

		#region constructor

		/// <summary>
		/// base constructor
		/// </summary>
		public NNPattern( )
		{
			arrayInput = new ArrayList();
			arrayOutput = new ArrayList();
			arrayCalculated = new ArrayList();

			nPatternID++;
			nCurrentID = nPatternID;

		}



		/// <summary>
		/// constructor taking array lists
		/// </summary>
		/// <param name="arrayInput"></param>
		/// <param name="arrayOutput"></param>
		public NNPattern( ArrayList arrayInput, ArrayList arrayOutput ):base()
		{
			this.arrayInput = arrayInput;
			this.arrayOutput = arrayOutput;
	
		}


		#endregion

		/// <summary>
		/// get the in set array
		/// </summary>
		public ArrayList ArrayInput
		{
			get
			{
				return arrayInput;
			}
		}

		/// <summary>
		/// get the out set array
		/// </summary>
		public ArrayList ArrayOutputDesired
		{
			get
			{
				return arrayOutput;
			}
		}
		/// <summary>
		/// get the out set array
		/// </summary>
		public ArrayList ArrayCalculated
		{
			get
			{
				return this.arrayCalculated;
			}
			set
			{
				this.arrayCalculated = value;
			}
		}


		/// <summary>
		/// get the pattern id
		/// </summary>
		public int PatternID
		{
			get
			{
				return nCurrentID;
			}
		}

	

		/// <summary>
		/// save the pattern
		/// </summary>
		public virtual void Save()
		{
			
		
		}

		/// <summary>
		/// load the pattern
		/// </summary>
		public virtual void Load()
		{
			
		}

		/// <summary>
		/// make a copy of the pattern
		/// </summary>
		/// <param name="pattern"></param>
		public void Copy( NNPattern pattern )
		{
		

			arrayInput = ( ArrayList )pattern.ArrayInput.Clone();
			arrayOutput = ( ArrayList )pattern.ArrayOutputDesired.Clone();
			this.arrayCalculated = ( ArrayList )pattern.arrayCalculated.Clone();

			nPatternID = pattern.PatternID;
		}


		/// <summary>
		/// set the input value
		/// </summary>
		/// <param name="nIndex"></param>
		/// <param name="dValue"></param>
		public void SetInValue( int nIndex, double dValue )
		{
				arrayInput[ nIndex ] = dValue;	
		}


		/// <summary>
		/// set the output value
		/// </summary>
		/// <param name="nIndex"></param>
		/// <param name="dValue"></param>
		public void SetOutValue( int nIndex, double dValue )
		{
				arrayOutput[ nIndex ] = dValue;		
		
		}

		/// <summary>
		/// get the input value at the given index
		/// </summary>
		/// <param name="nIndex"></param>
		/// <returns></returns>
		public double InputValue( int nIndex )
		{
	
			double d = Convert.ToDouble(arrayInput[ nIndex ]);
			return d;

		}

		/// <summary>
		/// get the output value at the given index
		/// </summary>
		/// <param name="nIndex"></param>
		/// <returns></returns>
		public double OutputValue( int nIndex )
		{
			

			double f = Convert.ToDouble(arrayOutput[ nIndex ]);
			return f;
		
		
		}

		public int InputSize()
		{
			return arrayInput.Count;
		}

		public int OutputSize()
		{
			return arrayOutput.Count;
		}


	
			
	}
}
